package com.egao.trade.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
//import com.egao.trade.mapper.TradeGoodsMapper;
import com.egao.trade.entity.TradeGoods;
import com.egao.trade.service.TradeGoodsService;
import org.springframework.stereotype.Service;
import com.egao.trade.biz.TradeGoodsBiz;
import net.sf.json.JSONObject;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
//import javax.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 外贸商品服务实现类
 * @author : Doman
 * @date : 2022-04-18 15:49:37
 * @version ：1.0
 */
@Service
public class TradeGoodsServiceImpl /*extends ServiceImpl<TradeGoodsMapper, TradeGoods> */implements TradeGoodsService {

	@Autowired
	private TradeGoodsBiz tradeGoodsBiz;

  @Override
  public JsonResult list(PageResult2<T> page, TradeGoods tradeGoods, User loginUser)  throws Exception{
    return tradeGoodsBiz.list(page,tradeGoods,loginUser);
  }

  @Override
  public JsonResult list(TradeGoods tradeGoods, User loginUser) {
    return JsonResult.ok().setData(tradeGoodsBiz.list(tradeGoods,loginUser));
  }

  @Override
  public JsonResult getById(TradeGoods tradeGoods) {
    return JsonResult.ok().setData(tradeGoodsBiz.getById(tradeGoods));
  }

  @Transactional
  @Override
  public JsonResult save(TradeGoods tradeGoods, User loginUser) {
    if (tradeGoodsBiz.save(tradeGoods, loginUser)) {
      return JsonResult.ok("添加成功");
    }
    return JsonResult.error("添加失败");
  }

  @Transactional
  @Override
  public JsonResult update(TradeGoods tradeGoods, User loginUser) {
    if (tradeGoodsBiz.update(tradeGoods, loginUser)) {
      return JsonResult.ok("修改成功");
    }
    return JsonResult.error("修改失败");
  }

  @Transactional
  @Override
  public JsonResult remove(TradeGoods tradeGoods, User loginUser) {
    if (tradeGoodsBiz.remove(tradeGoods, loginUser)) {
      return JsonResult.ok("删除成功");
    }
    return JsonResult.error("删除失败");
  }

}
